package com.lineage.server.command.executor;

import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_PacketBox;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.world.World;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1ChatNG implements L1CommandExecutor {
  private static final Log _log = LogFactory.getLog(L1ChatNG.class);
  
  public static L1CommandExecutor getInstance() {
    return new L1ChatNG();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      StringTokenizer st = new StringTokenizer(arg);
      String name = st.nextToken();
      int time = Integer.parseInt(st.nextToken());
      L1PcInstance tg = World.get().getPlayer(name);
      if (tg != null) {
        tg.setSkillEffect(4002, time * 60 * 1000);
        tg.sendPackets((ServerBasePacket)new S_PacketBox(36, time * 60));
        tg.sendPackets((ServerBasePacket)new S_ServerMessage(286, String.valueOf(time)));
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(287, name));
      } else {
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(73, name));
      } 
    } catch (Exception e) {
      _log.error("错误的GM指令格式: " + getClass().getSimpleName() + " 执行的GM:" + pc.getName());
      pc.sendPackets((ServerBasePacket)new S_ServerMessage(261));
    } 
  }
}
